<?php

namespace App\Http\Middleware;

use Closure;

class CheckUserStatus
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next,$status=1)
    {
        $user=auth()->user();
        if(empty($user) || $user->status!=$status){
            throw new \Exception('用户当前状态不可用');
        }
        return $next($request);
    }
}
